package com.example.controller;

import com.example.pojo.Shift;
import com.example.service.IShiftService;
import com.example.vo.ResultVo;
import com.example.vo.per.ShiftParameterSet;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 班次表 前端控制器
 * </p>
 *
 * @author wsl
 * @since 2022-04-14
 */
@RestController
@RequestMapping("/shift")
@Api(tags = "班次表",value = "")
@CrossOrigin(allowCredentials = "true")
public class ShiftController {

    @Autowired
    private IShiftService iss;

    @PostMapping("")
    @ApiModelProperty("新增班次")
    public ResultVo addSc(@RequestBody ShiftParameterSet sps){
        if (iss.savess(sps)){
            return ResultVo.ok();
        }
        return ResultVo.error();
    }

    @GetMapping("")
    @ApiModelProperty("查询所有班次")
    public List<Map<String, Object>> selAll(){
        return iss.selByUncond();
    }

    @DeleteMapping("/{ids}")
    @ApiModelProperty("删除班次-真")
    public ResultVo delAll(@PathVariable("ids") Integer[] ids){
        iss.delAll(ids);
        return ResultVo.ok();
    }
}
